{template 'common/header'}
<link rel="stylesheet" href="https://cdn.oss.664773288.com/loohu_order/layui/css/layui.css">
<style>
    .table thead tr th{
        text-align: center;
    }
    .table tbody tr td{
        text-align: center;
        vertical-align: middle;
    }
</style>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="panel panel-default">
            <div class="panel-heading" style="height:38px;">
                    活动列表           
            </div>
            <div class="panel-body">
            <table class="layui-table">
                <colgroup>
                    <col width="100">
                    <col width="120">
                    <col width="100">
                    <col width="100">
                    <col width="120">
                    <col width="240">
                </colgroup>
                    <thead>
                        <tr>
                            <th>病例详情</th>
                            <th>时间</th>
                            <th>地址</th>
                            <th>经度</th>
                            <th>纬度</th>
                            <th>操作</th>
                         </tr>
                    </thead>	  
                        <tbody>
                        {loop $ncovlist $index $val}
                            <tr>
                                <td>{$val['findtext']}</td>
                                <td>{$val['findtime']}</td>
                                <td>{$val['address']}</td>
                                <td>{$val['lng']}</td>
                                <td>{$val['lat']}</td>
                                <td>
                                    <div class="btn-group-vertical" data-aid="{$val['id']}">
                                        <button type="button" class="layui-btn layui-btn-small btn-jump" data-type="edit">修改</button>
                                        <button type="button" class="layui-btn layui-btn-small btn-jump" data-type="delete">删除</button>
                                    </div>
                                </td>
                            </tr>
                        {/loop}
                    </tbody>
                </table>
            </div>
            <div class="panel-footer" style="text-align: center;">
                {$pageInfo['pager']}
            </div>
        </div>
    </div>
</div>
<script>
    var baseURL=new Array();
    baseURL['edit'] = "{php echo $this->createWebUrl('ncovadd');}";
    baseURL['delete'] = "{php echo $this->createWebUrl('ncovdelete') . '&actType=redpack';}";
    $('.btn-jump').click(function(){
        var aid = $(this).parent().attr('data-aid');
        var type = $(this).attr('data-type');
        var url = '';
        if (type == 'delete') {
            url = baseURL[type];
            if (confirm("确定删除？")) {
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: {'aid' : aid},
                    success: function(obj){
                        //console.log(obj);
                        if (obj == 'success') {
                            alert('删除成功');
                            window.location.reload();
                        } else {
                            alert('删除失败');
                            window.location.reload();
                        }
                    },
                    fail : function(result) {
                        alert('fail : ' + result.message);
                        window.location.reload();
                    }
                });
            }
        }else{
            url = baseURL[type] + "&aid=" + aid;
            window.location.href = url;
        }
    })
</script>
<script type="text/javascript" src="https://cdn.oss.664773288.com/loohu_order/layui/layui.js"></script>
{template 'common/footer'}